<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HuiCMF-后台管理系统-v3.0</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__STATIC_ADMIN__css/font.css">
    <link rel="stylesheet" href="__STATIC_ADMIN__css/weadmin.css">
    <link rel="stylesheet" href="__STATIC_ADMIN__css/style.css">
    <style>
        #embed-captcha {margin: 0 auto;}
        .show {display: block;}
        .hide {display: none;}
        #notice {color: red;}
    </style>
    <script>
        if (window != top) {
            top.location.href="{:url('login/index')}";
        }
    </script>
</head>
<body class="login-bg" style="background: url({:url('getbing_bgpic')});background-size:cover;">

<div class="login">
    <div class="message">小灰灰内容管理系统-后台管理系统</div>
    <div id="darkbannerwrap"></div>

    <form method="post" class="layui-form" action="javascript:;" onsubmit="return dosub(this)">
        {:token()}
        <div class="layui-form-item input-item">
            <label for="username">用户名</label>
            <input name="username" id="username" placeholder=""  type="text" lay-verify="required" class="layui-input"  required="required">
        </div>
        <hr class="hr15">
        <div class="layui-form-item input-item">
            <label for="password">密码</label>
            <input name="password" id="password" lay-verify="required" placeholder=""  type="password" class="layui-input" required="required">
        </div>
        {if get_config('login_code')==1}
        <hr class="hr15">
        <div class="layui-form-item input-item">
            <label for="captcha">验证码</label>
            <input type="text" name="code" id="code" class="layui-input verify_inputlayui-input" lay-verify="required"  placeholder="" required="required" style="float:left; width: 40%">
            <img src="{:url('verify')}" id="imgVcode" alt="captcha" title="点击刷新验证码" border="0" class="verifyimg" onclick="this.src=this.src+'?'" style="float:right;height: 50px;"/>
        </div>
        {/if}
        {if get_config('login_code')==2}
        <hr class="hr15">
        <div id="embed-captcha"></div>
        <p id="wait" class="show">正在加载验证码......</p>
        <p id="notice" class="hide">请先完成验证</p>
        {/if}

        <hr class="hr20">
        <input type="hidden" id="dosubmit" value="1">
        <input class="loginin" value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
    </form>
</div>
<div id="click_pic">
    <a href="javascript:;" class="click_pic click_pic_a" title="上一个图像"></a>
    <a href="javascript:;" class="click_pic click_pic_b" title="下一个图像"></a>
</div>
<div id="focus_ovr" data-bm="21"></div>
<!-- 底部结束 -->
{include file='footer'/}
<script src="__STATIC_ADMIN__js/gt.js"></script>
<script>
    /*$(document).ready(function () {
        if (window != top) {
            top.location.href = location.href;
        }
    });*/
    $(".login .layui-input").click(function (e) {
      console.log(e)
      e.stopPropagation();
      $(this).addClass("layui-input-focus").find(".layui-input").focus();
    });
    $(".login .layui-input").focus(function () {
      $(this).parent().addClass("layui-input-focus");
    });

    $(".login .layui-input").blur(function () {
      $(this).parent().removeClass("layui-input-focus");
      if ($(this).val() != "") {
        $(this).parent().addClass("layui-input-active");
      } else {
        $(this).parent().removeClass("layui-input-active");
      }
    })


    {php}if(get_config('login_code')==2){ {/php}
    var handlerEmbed = function (captchaObj) {
        $("#embed-submit").click(function (e) {
            var validate = captchaObj.getValidate();
            if (!validate) {
                $("#notice")[0].className = "show";
                setTimeout(function () {
                    $("#notice")[0].className = "hide";
                }, 2000);
                e.preventDefault();
            }
        });
        // 将验证码加到id为captcha的元素里，同时会有三个input的值：geetest_challenge, geetest_validate, geetest_seccode
        captchaObj.appendTo("#embed-captcha");
        captchaObj.onReady(function () {
            $("#wait")[0].className = "hide";
        });
    };
    $.ajax({
        // 获取id，challenge，success（是否启用failback）
        url: "{:url('StartCaptchaServlet')}?t=" + (new Date()).getTime(), // 加随机数防止缓存
        type: "get",
        dataType: "json",
        success: function (data) {
            // 使用initGeetest接口
            // 参数1：配置参数
            // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
            initGeetest({
                gt: data.gt,
                width: '100%',
                challenge: data.challenge,
                new_captcha: data.new_captcha,
                product: "popup", // 产品形式，包括：float，embed，popup，bind。注意只对PC版验证码有效
                offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
            }, handlerEmbed);
        }
    });
    {php}}{/php}
    function dosub() {
        $.post("{:url('index')}",{
            username:$('#username').val(),
            password:$('#password').val(),
            code:$('#code').val(),
            dosubmit:$('#dosubmit').val(),
            geetest_challenge:$("input[name='geetest_challenge']").val(),
            geetest_validate:$("input[name='geetest_validate']").val(),
            geetest_seccode:$("input[name='geetest_seccode']").val(),
        },function (res) {
            if(res.status=='1001'){
                $('#imgVcode').attr("src","{:url('verify')}"+"?" + Math.random());
                layer.msg(res.msg,{'icon':2});
            }
            if(res.status=='1002'||res.status=='1003'){
                layer.msg(res.msg,{'icon':2},function () {
                    location.reload();
                });
            }
            if(res.status=='1004'){
                layer.msg(res.msg,{'icon':2});
            }
            if(res.status==1){
                layer.msg(res.msg,{'icon':1},function () {
                    window.location.href="{:url('index/index')}";
                });
            }
        })
    }

    var i = 0;
    $(".click_pic_a").click(function () {
        i += 1;
        if (i <= 7) {
            $(".login-bg").css({
                "background": "url({:url('getbing_bgpic')}?idx=" + i + ")",
                "transition": "500ms ease 500ms",
                "-webkit-transition": "500ms ease 500ms",
                "background-size":'cover'
            });
            $(".click_pic_a").css("opacity", "1")
        } else {
            i = 7;
            alert("没有了")
        }
    });
    $(".click_pic_b").click(function () {
        i -= 1;
        if (i >= 0) {
            $(".login-bg").css({
                "background": "url({:url('getbing_bgpic')}?idx=" + i + ")",
                "transition": "500ms ease 500ms",
                "-webkit-transition": "500ms ease 500ms",
                "background-size":'cover'
            });
            $(".click_pic_b").css("opacity", "1")
        } else {
            i = 0;
            alert("没有了");
        }
    })
</script>
</body>
</html>